package org.app.web.controllers;

import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.app.model.entities.JmbUsers;
import org.app.model.session.JmbUsersFacade;

/**
 *
 * @author Santiago
 */
@ManagedBean
@RequestScoped
public class RegisterController implements Serializable{
  
  @EJB
  private JmbUsersFacade jmbUsersFacade;
  private JmbUsers jmbUser;
  

  /**
   * Creates a new instance of RegisterController
   */
  public RegisterController() {
     jmbUser= new JmbUsers();
  }

  public void registrarCuenta(){
    
    boolean reglas = false;
    if(jmbUser.getUserMail().length()>10){
      reglas = true;
    }
    if(jmbUser.getUserJnick().length()>5){
      reglas = true;
    }
    if(jmbUser.getUserPassword().length()>5){
      reglas = true;
    }
    if(reglas){
      jmbUsersFacade.create(this.jmbUser);
    }
    
   
  }

  
  
  
  /**
   * @return the jmbUser
   */
  public JmbUsers getJmbUser() {
    return jmbUser;
  }

  /**
   * @param jmbUser the jmbUser to set
   */
  public void setJmbUser(JmbUsers jmbUser) {
    this.jmbUser = jmbUser;
  }
  
  
}
